/*
 * ComboBoxTableCellRenderer.java
 *
 * Created on 22 juni 2007, 9:51
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package net.jwtools.tmt.ui.renderer;

import java.awt.Component;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author mesui00
 */
public class ComboBoxTableCellRenderer extends JComboBox implements TableCellRenderer {
    
    /** Creates a new instance of ComboBoxTableCellRenderer */
    public ComboBoxTableCellRenderer() {
    }

    public void setAvailableValues(Object[] val) {
        setModel(new DefaultComboBoxModel(val));
    }
    
    public void setAvailableValues(List val) {
        setAvailableValues(val.toArray());
    }
    
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        setSelectedItem(value);
        return this;
    }
    
}
